package com.sike.netty.im.client.listener;

import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
import lombok.extern.slf4j.Slf4j;

/**
 * 连接监听器，负责监听启动时连接失败，重新连接功能
 *
 * @author chenssy
 * @date 2023/09/26
 */
@Slf4j
public class ReconnectListener implements ChannelFutureListener {
    @Override
    public void operationComplete(ChannelFuture future) throws Exception {
        if (!future.isSuccess()) {
            // 直接传播 ChannelInactive 事件，交由 ReconnectHandler 处理即可
            future.channel().pipeline().fireChannelInactive();
        }
    }
}
